<template>
  <div class="company-service">
    <!--    公司服务查询表单-->
    <div class="search">
      <div class="title">公司服务列表</div>
      <el-form :inline="true" :model="searchForm" label-width="120px" class="demo-form-inline" size="mini"
               ref="search">
        <el-form-item label='合同标题' prop="contractName">
          <el-input v-model="searchForm.contractName"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button @click="resetForm('search')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!--    新增公司服务按钮-->
    <el-row>
      <el-col>
        <el-button type="primary" @click="showAddCateDialog" size="mini">新增</el-button>
      </el-col>
    </el-row>

    <!--   公司服务列表-->
    <el-table
      :data="showTableData"
      stripe
      style="width: 100%"
      size="mini">
      <el-table-column
        type="index"
        width="50">
      </el-table-column>
      <el-table-column
        prop="contractName"
        label="合同标题">
      </el-table-column>
    </el-table>

    <!--      分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5, 10, 20, 30]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>

    <!--    增加公司服务对话框-->
    <el-dialog title="添加资质证照" :visible.sync="addDialogVisible" width="50%" @close="addDialogClosed">
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "CompanyService",
  data(){
    return{
      searchForm:{   //公司服务查询表单

      },
      currentPage: 1,  //当前页面
      pageSize:5,  //页面条数，默认为10条
      addDialogVisible: false,  //增加知识产权对话框
      tableData:[],  //服务器中请求的数据
      showTableData:[],  //分页的列表
    }
  },
  methods:{
    resetForm(formName){  //重置查询表单
      this.$refs[formName].resetFields();
    },
    onSubmit(){  //查询
      this.$message({
        message: '合同查询成功！',
        type:'success'
      })
    },
    showAddCateDialog() { //点击添加按钮
      this.addDialogVisible = true;
    },
    addDialogClosed(){  //关闭“添加合同”对话框
      this.addDialogVisible =false;
    },

    //分页
    handleSizeChange(val){  //每页条数变化
      this.pageSize =val;
      this.getTableData();
    },
    handleCurrentChange(val){  //当前页发生改变
      this.currentPage = val;
      this.getTableData();
    },
    getTableData(){  //获取数据
      let startIndex = (this.currentPage-1)*this.pageSize;
      let endIndex = startIndex+this.pageSize > this.tableData.length ? this.tableData.length : startIndex+this.pageSize;
      this.showTableData = this.tableData.slice(startIndex,endIndex);
    }
  },
  computed:{
    total(){ //总条数
      return this.tableData.length;
    }
  },
}
</script>

<style scoped>
.company-service{
  height: 100%;
}
.search{
  border: 1px solid #999999;
  border-radius: 3px;
  margin-bottom: 10px;
}
.title{
  color: white;
  background-color: rgb(55,75,118);
  font-size: 12px;
  height: 25px;
  line-height: 25px;
  padding-left:8px;
  margin-bottom: 10px;
}
</style>
